﻿using Abp.Authorization;
using Microsoft.AspNetCore.Mvc;
using Mt.Site.Application.ContentManagement.Preview.Dto;
using Mt.Site.Core.ContentManagement.Permissions;
using Mt.Site.Core.ContentManagement.Preview;
using System.Threading.Tasks;

namespace Mt.Site.Application.ContentManagement.Preview
{
    public class PreviewAppService : MtSiteAppServiceBase, IPreviewAppService
    {
        private readonly IPreviewDataManager _previewDataManager;


        public PreviewAppService(
            IPreviewDataManager previewDataManager)
        {
            _previewDataManager = previewDataManager;
        }

        [HttpPost]
        [AbpAuthorize(ContentPermissions.Pages_Manage_Content_Preview)]
        public async Task<PreviewTokenInfo> GetPreviewTokenAsync(PreviewTokenInput input)
        {
            return await _previewDataManager.GetPreviewTokenAsync(input);
        }

        [HttpPost]
        [AbpAuthorize(ContentPermissions.Pages_Manage_Content_Preview)]
        public async Task<PreviewTokenInfo> UpdateTokenExpireTimeAsync(SetPreviewExpireTimeInput input)
        {
            return await _previewDataManager.UpdateTokenExpireTimeAsync(input);
        }
    }
}
